import Poker from './poker'

/**
 * 2v2 房间内玩家模型
 * 回调函数需在外部文件实现后，通过绑定函数注入到实例上
 */


class R2V2Player {
  constructor() {
    // 基本信息
    this.uid = ''            // 玩家ID
    this.nickname = ''       // 玩家昵称
    this.profile = ''        // 头像（文件名或URL片段）
    this.position = 0        // 座位位置（1-4）
    this.camp = 0        // 阵营，阵营从1开始，每个人都以自己为中心

    // 手牌与装备
    /** @type {Poker[]} */ this.pokers = []        // 手牌
    /** @type {Poker[]} */ this.defend = []        // 防具区
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.defend_function = null
    /** @type {Poker[]} */ this.attack = []        // 武器区
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.attack_function = null
    /** @type {Poker[]} */ this.horse1 = []        // +1 马
    /** @type {Poker[]} */ this.horse2 = []        // -1 马

    // 生存与血量
    this.onlive = true        // 存活状态
    this.blood = 0            // 当前血量
    this.blood_limit = 0      // 血量上限

    // 临时状态
    this.wine_state = false    // 是否处于酒状态
    this.focus_state = false   // 是否处于强中状态
    this.unskill_state = false // 是否处于无法使用技能状态
    this.lock_state = false    // 是否处于被锁定状态

    // 角色
    this.charactor = 0        // 选择的角色（标识）
    this.charactor_now = ''    // 当前展示的角色图片
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.charactor_function = null
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.charactor_function_ed = null // 武将被动技能

    // 判定区
    /** @type {Poker[]} */ this.judge = []
    /** @type {string} */ this.judge_name = ''
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.judge_function = null

    // 技能占位（可运行期绑定）
    this.skill1_name = ''
    /** @type {Poker[]} */ this.skill1 = []
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.skill1_function = null

    this.skill2_name = ''
    /** @type {Poker[]} */ this.skill2 = []
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.skill2_function = null

    this.skill3_name = ''
    /** @type {Poker[]} */ this.skill3 = []
    /** @type {(player: R2V2Player, ctx?: any) => void | any | null} */ this.skill3_function = null
  }

  /** 绑定防具效果函数，被动处罚 */
  bindDefendFunction(fn) { this.defend_function = typeof fn === 'function' ? fn : null }
  /** 绑定武器效果函数，主动触发 */
  bindAttackFunction(fn) { this.attack_function = typeof fn === 'function' ? fn : null }

  /** 绑定武将技能函数 */
  bindCharactorFunction(fn) { this.charactor_function = typeof fn === 'function' ? fn : null }

  /** 绑定判定牌回调 */
  bindJudgeFunction(fn) { this.judge_function = typeof fn === 'function' ? fn : null }

  /** 绑定技能1回调 */
  bindSkill1Function(fn) { this.skill1_function = typeof fn === 'function' ? fn : null }
  /** 绑定技能2回调 */
  bindSkill2Function(fn) { this.skill2_function = typeof fn === 'function' ? fn : null }
  /** 绑定技能3回调 */
  bindSkill3Function(fn) { this.skill3_function = typeof fn === 'function' ? fn : null }
}
export default R2V2Player


